<template>
    <div class="friend-link-wrapper">
        <el-row :gutter="10">
            <el-col style="line-height:40px;font-size:18px" :span="4">
                <i class="fa fa-link"></i>&nbsp;友情链接：</el-col>
            <el-col v-for="(item, key, index) in friendLink" :key="index" :span="4">
                <el-select @change="change" v-model="value" :placeholder="key">
                    <el-option v-for="(one, index) in item" :key="index" :value="one.url" :label="one.name"></el-option>
                </el-select>
            </el-col>
        </el-row>
        <!-- <div class="back-top">fdfsdfsd</div> -->
        <transition name="el-fade-in-linear">
            <div class="back-top" v-if="scrollTop>300" @click="backTop">
                <i class="fa fa-chevron-up"></i>
            </div>
        </transition>
    </div>
</template>

<script>
    import { scrollTop, backTop } from '../../scripts/windowScroll'

    export default {
        name: 'friendLink',
        data: function () {
            return {
                friendLink: null,
                value: null,
                scrollTop: document.documentElement.scrollTop
            }
        },
        methods: {
            openTab(url) {
                var newTab = window.open('about:blank');
                newTab.location.href = url;
            },
            change(val) {
                this.openTab(val)
                this.value = null
            },
            backTop() {
                backTop()
            }
        },
        mounted() {
            this.$emitter.addListener('get-scrollTop', data => {
                this.scrollTop = data
            })
            this.$$http("GET_FRIEND_LINK").then(data => {
                this.friendLink = data;
            })
        }
    }
</script>

<style lang="scss">
    .friend-link-wrapper {
      margin-top: 40px;
      .back-top {
        position: fixed;
        bottom: 30px;
        right: 20px;
        width: 55px;
        height: 55px;
        border-radius: 50%;
        background: #409eff;
        text-align: center;
        line-height: 55px;
        color: #fff;
        font-size: 20px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        cursor: pointer;
      }
      .el-input__inner {
        border: 1px solid #5a5e66;
      }
      input::-webkit-input-placeholder {
        color: #5a5e66;
      }
      input::-moz-input-placeholder {
        color: #5a5e66;
      }
      input::-ms-input-placeholder {
        color: #5a5e66;
      }
    }
</style>